package com.qf.mrmd.controller;

import com.qf.mrmd.entity.SysUser;
import com.qf.mrmd.result.ResponseCode;
import com.qf.mrmd.result.ResponseData;
import com.qf.mrmd.service.SysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (SysUser)表控制层
 *
 * @author makejava
 * @since 2021-07-21 10:38:15
 */
@RestController
@RequestMapping("sysUser")
public class SysUserController {
    /**
     * 服务对象
     */
    @Resource
    private SysUserService sysUserService;

    @ApiOperation(value = "获取用户微信登录状态")
    @GetMapping("/login/{code}")
    public ResponseData login(@PathVariable String code){
        return sysUserService.login(code);
    }

    @ApiOperation(value = "保存微信用户信息")
    @PutMapping("/")
    public ResponseData saveUserInfo(@RequestBody String userInfo){
        ResponseData update = sysUserService.update(userInfo);
        return update;
    }

    @ApiOperation(value = "后台登录接口")
    @PostMapping("/adminlogin")
    public ResponseData adminLogin(@RequestBody SysUser sysUser) throws Exception{
        //System.out.println(sysUser.getUname());
        SysUser user = sysUserService.adminLogin(sysUser);
        return new ResponseData(user);
    }

}
